Skip to content

fix(laravel): ignore non-string values in DateFilter - #8902

Open
BenMacha wants to merge 1 commit into
api-platform:5.0from
BenMacha:fix-laravel-date-filter-array-5-0
Open

BenMacha wants to merge 1 commit into
api-platform:5.0from
BenMacha:fix-laravel-date-filter-array-5-0

Conversation

@BenMacha

Copy link
Copy Markdown
Contributor
Q A
Branch? 5.0
Tickets -
License MIT
Doc PR -

The Laravel DateFilter returns a 500 when an operator gets an array instead of a string:

GET /api/books?publicationDate[gt][]=2024-01-01
  • before: 500, TypeError: DateFilter::getDateTime(): Argument #1 ($value) must be of type string, array given
  • after: 200, the invalid value is ignored, like an unparsable date already is

The Doctrine DateFilterTrait already skips non-string values, and no validation rule protects this parameter on the Laravel side (its schema type is date). The fix makes getDateTime() return null for anything that is not a string. Covered by testDateFilterIgnoresNonStringValue in src/Laravel/Tests/EloquentTest.php.

A nested array such as ?publicationDate[gt][]=2024-01-01 reached DateFilter::getDateTime(string)
and raised a TypeError (500). Non-string values are now ignored, like the Doctrine DateFilter
does.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T08:59:04.064180Z df1cea2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@BenMacha
BenMacha force-pushed the fix-laravel-date-filter-array-5-0 branch from df1cea2 to 78a8c8e Compare November 30, 2026 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant